home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 8
/
The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO
/
g_quake
/
dpt106.zip
/
WEAPONS.QC
< prev
next >
Wrap
Text File
|
1996-11-09
|
54KB
|
1,875 lines
/*
DeathMatch Power Toys v 1.06 final
by Piramida
*/
void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
void () player_run;
void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
void(vector org, vector vel, float damage) SpawnBlood;
void() SuperDamageSound;
void() MissileMove;
void() MissileRemove;
// called by worldspawn
void() W_Precache =
{
precache_sound ("hknight/hit.wav"); //grappling hook
precache_sound ("weapons/r_exp3.wav"); // new rocket explosion
precache_sound ("weapons/rocket1i.wav"); // spike gun
precache_sound ("weapons/sgun1.wav");
precache_sound ("weapons/guncock.wav"); // player shotgun
precache_sound ("weapons/ric1.wav"); // ricochet (used in c code)
precache_sound ("weapons/ric2.wav"); // ricochet (used in c code)
precache_sound ("weapons/ric3.wav"); // ricochet (used in c code)
precache_sound ("weapons/spike2.wav"); // super spikes
precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code)
precache_sound ("weapons/grenade.wav"); // grenade launcher
precache_sound ("weapons/bounce.wav"); // grenade bounce
precache_sound ("weapons/shotgn2.wav"); // super shotgun
precache_sound ("shalrath/attack2.wav");
precache_sound2 ("blob/land1.wav"); // chain go splorch!
};
float() crandom =
{
return 2*(random() - 0.5);
};
//============================================================================
vector() wall_velocity =
{
local vector vel;
vel = normalize (self.velocity);
vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
vel = vel + 2*trace_plane_normal;
vel = vel * 200;
return vel;
};
/*
================
SpawnMeatSpray
================
*/
void(vector org, vector vel) SpawnMeatSpray =
{
local entity missile, mpuff;
local vector org;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_BOUNCE;
missile.solid = SOLID_NOT;
makevectors (self.angles);
missile.velocity = vel;
missile.velocity_z = missile.velocity_z + 250 + 50*random();
missile.avelocity = '3000 1000 2000';
// set missile duration
missile.nextthink = time + 1;
missile.think = SUB_Remove;
setmodel (missile, "progs/zom_gib.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, org);
};
/*
================
SpawnBlood
================
*/
void(vector org, vector vel, float damage) SpawnBlood =
{
particle (org, vel*0.1, 73, damage*2);
};
/*
================
spawn_touchblood
================
*/
void(float damage) spawn_touchblood =
{
local vector vel;
vel = wall_velocity () * 0.2;
SpawnBlood (self.origin + vel*0.01, vel, damage);
};
/*
================
SpawnChunk
================
*/
void(vector org, vector vel) SpawnChunk =
{
particle (org, vel*0.02, 0, 10);
};
/*
==============================================================================
MULTI-DAMAGE
Collects multiple small damages into a single damage
==============================================================================
*/
entity multi_ent;
float multi_damage;
void() ClearMultiDamage =
{
multi_ent = world;
multi_damage = 0;
};
void() ApplyMultiDamage =
{
if (!multi_ent)
return;
T_Damage (multi_ent, self, self, multi_damage);
};
void(entity hit, float damage) AddMultiDamage =
{
if (!hit)
return;
if (hit != multi_ent)
{
ApplyMultiDamage ();
multi_damage = damage;
multi_ent = hit;
}
else
multi_damage = multi_damage + damage;
};
/*
==============================================================================
BULLETS
==============================================================================
*/
/*
================
TraceAttack
================
*/
void(float damage, vector dir) TraceAttack =
{
local vector vel, org;
vel = normalize(dir + v_up*crandom() + v_right*crandom());
vel = vel + 2*trace_plane_normal;
vel = vel * 200;
org = trace_endpos - dir*4;
if (trace_ent.takedamage)
{
SpawnBlood (org, vel*0.2, damage);
AddMultiDamage (trace_ent, damage);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
};
/*
================
FireBullets
Used by shotgun and enemy soldier firing
Go to the trouble of combining multiple pellets into a single damage call.
================
*/
void(float shotcount, vector dir, vector spread) FireBullets =
{
local vector direction;
local vector src;
makevectors(self.v_angle);
src = self.origin + v_forward*10;
src_z = self.absmin_z + self.size_z * 0.7;
ClearMultiDamage ();
while (shotcount > 0)
{
direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
traceline (src, src + direction*2048, FALSE, self);
if (trace_fraction != 1.0)
TraceAttack (4, direction);
shotcount = shotcount - 1;
}
ApplyMultiDamage ();
};
/*
================
W_FireShotgun
bit enhanced
================
*/
void() W_FireShotgun =
{
local vector dir;
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 100000);
FireBullets (15, dir, '0.05 0.05 0');
};
/*
==============================================================================
ROCKETS
==============================================================================
*/
void() MissileThink;
void() s_explode1 = [0, s_explode2] {};
void() s_explode2 = [1, s_explode3] {};
void() s_explode3 = [2, s_explode4] {};
void() s_explode4 = [3, s_explode5] {};
void() s_explode5 = [4, s_explode6] {};
void() s_explode6 = [5, SUB_Remove] {};
void() BecomeExplosion =
{
self.movetype = MOVETYPE_NONE;
self.velocity = '0 0 0';
self.touch = SUB_Null;
setmodel (self, "progs/s_explod.spr");
self.solid = SOLID_NOT;
s_explode1 ();
};
void() T_SMissileTouch =
{
local float damg;
if (other == self.owner)
return; // don't explode on owner
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
if(other.isprotected == 0)
{
damg = 100 + random()*50;
sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
if (other.health)
{
if (other.classname == "monster_shambler")
damg = damg * 0.5; // mostly immune
T_Damage (other, self, self.owner, damg );
}
}
else
{
sound (self, CHAN_WEAPON, "weapons/tink1.wav", 1, ATTN_NORM);
}
// don't do radius damage to the other, because all the damage
// was done in the impact
T_RadiusDamage (self, self.owner, 75, other);
self.origin = self.origin - 8*normalize(self.velocity);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion ();
};
void() T_MissileTouch =
{
local float damg;
if (other == self.owner)
return; // don't explode on owner
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
damg = 80 + random()*20;
if (other.health)
{
if (other.classname == "monster_shambler")
damg = damg * 0.5; // mostly immune
T_Damage (other, self, self.owner, damg );
}
// don't do radius damage to the other, because all the damage
// was done in the impact
T_RadiusDamage (self, self.owner, 80, other);
// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
self.origin = self.origin - 8*normalize(self.velocity);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion ();
};
/*
===================
Super Missile
(target search procedure is close to Vhold's
homing missile)
remake by Piramida
===================
*/
entity() MissileFindTarget;
float(entity targ) visible;
float(entity targ) infront;
void() W_FireRocket =
{
local entity missile, mpuff, head;
local float number;
number = 0;
head = findradius(self.origin, 100000);
while (head)
{
if ((head.classname == "Missile") && (head.owner == self))
{
number = number + 1;
if (number >= 10)
{
sprint(self, "10 Missiles limit reached\n");
return;
}
}
head = head.chain;
}
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
self.ammo_shells = self.ammo_shells - 1;
self.ammo_cells = self.ammo_cells - 1;
self.ammo_nails = self.ammo_nails - 1;
sprint(self,"Reloading Missile...\n");
sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
self.punchangle_x = -5;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_FLYMISSILE;
missile.solid = SOLID_BBOX;
missile.classname = "Missile";
// set missile speed
makevectors (self.v_angle);
missile.velocity = aim(self, 1000);
missile.velocity = missile.velocity * 50;
missile.angles = vectoangles(missile.velocity);
missile.avelocity = '500 0 0' * random() + '0 500 0' * random() + '0 0 500' * random();
missile.touch = T_SMissileTouch;
// set missile duration
missile.nextthink = time + 0.1;
missile.think = MissileThink;
missile.enemy = world;
missile.spikes = -20;
missile.wait = 0;
setmodel (missile, "progs/v_spike.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, self.origin + v_forward*8 + '0 0 16');
};
entity() MissileFindTarget =
{
local entity head, selected;
local float dist;
dist = 100000;
selected = world;
head = findradius(self.origin, 100000);
while(head)
{
if( (head.health > 1) && (head != self.owner) /*&& (head.classname == "player")*/ )
{
traceline(self.origin,head.origin,TRUE,self);
if ( (trace_fraction >= 1) && (vlen(head.origin - self.origin) < dist) )
{
selected = head;
dist = vlen(head.origin - self.origin);
}
}
head = head.chain;
}
if (selected != world)
{
sound (self,CHAN_WEAPON,"weapons/ric2.wav", 1,ATTN_NORM);
if (selected.classname == "player")
{
sprint (self.owner,"Now hunting : ");
sprint (self.owner,selected.netname);
sprint (selected,self.owner.netname);
sprint (selected,"s' Locked a Missile on You !!!\n");
}
sprint (self.owner,"\n");
self.wait = 0;
self.spikes = 0;
self.num = vlen(selected.origin - self.origin) * -0.005;
}
return selected;
};
void() MissileThink =
{
local vector dir, vtemp;
if ( (self.enemy != world) && (self.enemy.health < 1) )
{
self.enemy = world;
self.velocity = self.velocity * -0.2;
self.spikes = -10;
}
if ( (self.enemy == world) || (self.enemy.health < 1) )
self.enemy = MissileFindTarget();
if (self.enemy != world)
{
traceline(self.origin,self.enemy.origin,TRUE,self);
if (trace_fraction < 1)
{
self.enemy = world;
self.velocity = self.velocity * -0.2;
self.spikes = -10;
self.nextthink = time + 0.2;
self.think = MissileThink;
return;
}
vtemp = self.enemy.origin + '0 0 10';
dir = normalize(vtemp - self.origin);
self.velocity = dir * 200;
self.num = self.num + 1;
if(self.num >= 0)
{
sound (self,CHAN_WEAPON,"weapons/ric1.wav", 1,ATTN_NORM);
self.num = vlen(self.enemy.origin - self.origin) * -0.005;
}
self.nextthink = time + 0.1;
}
else // No player to aim
{
self.wait = self.wait + 1;
self.spikes = self.spikes + 1;
if(self.wait >= 300)
{
BecomeExplosion ();
return;
}
if(self.spikes == 10)
{
self.velocity = self.velocity * -1;
self.spikes = 0;
}
self.nextthink = time + 0.2;
}
self.think=MissileThink;
};
/*
================
W_FireSuperShotgun
remake by Piramida ->
Destructor, heh :)
================
*/
void() W_FireSuperShotgun =
{
local entity missile1, missile2, missile3, mpuff;
local float sl; //Shots Left that is
if(self.ammo_rockets < 3)
{
sl = self.ammo_rockets;
self.currentammo = self.ammo_rockets = 0;
}
else
{
sl = 3;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 3;
}
sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
self.punchangle_x = -4 * sl;
if(sl != 1)
{
missile1 = spawn ();
missile1.owner = self;
missile1.movetype = MOVETYPE_FLYMISSILE;
missile1.solid = SOLID_BBOX;
makevectors (self.v_angle + '0 6 0');
missile1.velocity = aim(self, 1000);
missile1.velocity = missile1.velocity * 800;
missile1.angles = vectoangles(missile1.velocity);
missile1.touch = T_MissileTouch;
missile1.nextthink = time + 5;
missile1.think = SUB_Remove;
setmodel (missile1, "progs/missile.mdl");
setsize (missile1, '0 0 0', '0 0 0');
setorigin (missile1, self.origin + v_forward*8 + '5 0 16');
missile2 = spawn ();
missile2.owner = self;
missile2.movetype = MOVETYPE_FLYMISSILE;
missile2.solid = SOLID_BBOX;
makevectors (self.v_angle + '0 -6 0');
missile2.velocity = aim(self, 1000);
missile2.velocity = missile2.velocity * 800;
missile2.angles = vectoangles(missile2.velocity);
missile2.touch = T_MissileTouch;
missile2.nextthink = time + 5;
missile2.think = SUB_Remove;
setmodel (missile2, "progs/missile.mdl");
setsize (missile2, '0 0 0', '0 0 0');
setorigin (missile2, self.origin + v_forward*8 + '-5 0 16');
}
if(sl > 2 || sl == 1)
{
missile3 = spawn ();
missile3.owner = self;
missile3.movetype = MOVETYPE_FLYMISSILE;
missile3.solid = SOLID_BBOX;
makevectors (self.v_angle);
missile3.velocity = aim(self, 1000);
missile3.velocity = missile3.velocity * 800;
missile3.angles = vectoangles(missile3.velocity);
missile3.touch = T_MissileTouch;
missile3.nextthink = time + 5;
missile3.think = SUB_Remove;
setmodel (missile3, "progs/missile.mdl");
setsize (missile3, '0 0 0', '0 0 0');
setorigin (missile3, self.origin + v_forward*8 + '0 0 16');
}
};
/*
===============================================================================
LIGHTNING
===============================================================================
*/
/*
=================
LightningDamage
=================
*/
void(vector p1, vector p2, entity from, float damage) LightningDamage =
{
local entity e1, e2;
local vector f;
f = p2 - p1;
normalize (f);
f_x = 0 - f_y;
f_y = f_x;
f_z = 0;
f = f*16;
e1 = e2 = world;
traceline (p1, p2, FALSE, self);
if (trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage*4);
T_Damage (trace_ent, from, from, damage);
if (self.classname == "player")
{
if (other.classname == "player")
trace_ent.velocity_z = trace_ent.velocity_z + 400;
}
}
e1 = trace_ent;
traceline (p1 + f, p2 + f, FALSE, self);
if (trace_ent != e1 && trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage*4);
T_Damage (trace_ent, from, from, damage);
}
e2 = trace_ent;
traceline (p1 - f, p2 - f, FALSE, self);
if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage*4);
T_Damage (trace_ent, from, from, damage);
}
};
void() W_FireLightning =
{
local vector org;
if (self.ammo_cells < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
/* explode if under water // commented out by Windows 95 setup :)
if (self.waterlevel > 1)
{
T_RadiusDamage (self, self, 35*self.ammo_cells, world);
self.ammo_cells = 0;
W_SetCurrentAmmo ();
return;
} */
if (self.t_width < time)
{
sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
self.t_width = time + 0.6;
}
self.punchangle_x = -2;
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = self.origin + '0 0 16';
traceline (org, org + v_forward*600, TRUE, self);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, self);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
WriteCoord (MSG_BROADCAST, trace_endpos_x);
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);
LightningDamage (self.origin, trace_endpos + v_forward*4, self, 10);
};
//=====================GRENADES================================================
void() GrenadeMoveUp;
void(float number, entity inflictor, float ox, float oy) shrapnel;
void() GrenadeExplode =
{
T_RadiusDamage (self, self.owner, 100, world);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion ();
};
void() GrenadeBomb =
{
shrapnel(1,self,50,0);
shrapnel(2,self,0,50);
shrapnel(3,self,0,0);
shrapnel(4,self,-50,0);
shrapnel(5,self,0,-50);
shrapnel(6,self,0,0);
shrapnel(7,self,50,0);
shrapnel(8,self,0,50);
shrapnel(9,self,0,0);
shrapnel(10,self,-50,-50);
T_RadiusDamage (self, self.owner, 100, self.owner);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
self.solid=SOLID_NOT;
BecomeExplosion ();
};
void() GrenadeTouch =
{
if (other == self.owner)
return; // don't explode on owner
if (other.takedamage == DAMAGE_AIM)
{
GrenadeExplode();
return;
}
sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
if (self.velocity == '0 0 0')
self.avelocity = '0 0 0';
};
/*
================
W_FireGrenade
================
*/
void() W_FireGrenade =
{
local entity missile, mpuff,head;
local float number; //How Many Grenades
if(self.currentammo < 4)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
number = 0;
head = findradius(self.origin, 100000);
while (head)
{
if ((head.classname == "grenade") && (head.owner == self))
{
number = number + 1;
if (number >= 5)
{
sprint(self, "You already have 5 active Mines.\n");
return;
}
}
head = head.chain;
}
self.currentammo = self.ammo_rockets = self.ammo_rockets - 4;
sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_BOUNCE;
missile.solid = SOLID_BBOX;
missile.classname = "grenade";
// set missile speed
makevectors (self.v_angle);
if (self.v_angle_x)
missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
else
{
missile.velocity = aim(self, 10000);
missile.velocity = missile.velocity * 600;
missile.velocity_z = 200;
}
missile.avelocity = '300 300 300';
missile.angles = vectoangles(missile.velocity);
missile.touch = GrenadeTouch;
// set missile duration
missile.nextthink = time + 2;
missile.think = GrenadeMoveUp;
setmodel (missile, "progs/grenade.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, self.origin);
};
/*
========
Grenade Bomb
by Piramida
=========
*/
void() DetonateAllGrenades =
{
local entity head;
head = findradius (self.origin, 100000);
self.num = 0;
while(head)
{
if((head.classname == "grenade") && (head.owner == self))
{
head.nextthink = time;
head.think = GrenadeBomb;
}
head = head.chain;
}
};
void() ChangeDirection;
void() GrenadeVibrate =
{
self.nextthink = time + 0.1;
T_RadiusDamage(self,self.owner,50,self.owner);
self.wait = self.wait + 1;
self.spikes = self.spikes - 1;
if(self.wait < 5)
self.think = GrenadeVibrate;
else
self.think = ChangeDirection;
if(self.spikes < 0)
self.think = GrenadeBomb;
};
void() ChangeDirection =
{
self.velocity = self.velocity * -1;
self.nextthink = time + 0.1;
self.think = GrenadeVibrate;
self.wait = 0;
};
void() GrenadeMoveUp =
{
local entity missile, mpuff;
self.movetype=MOVETYPE_NONE;
self.velocity='0 0 0';
self.nextthink=time + 0;
self.think = SUB_Remove;
missile=spawn ();
missile.owner=self.owner;
missile.movetype=MOVETYPE_FLYMISSILE;
missile.solid=SOLID_BBOX;
missile.classname="grenade";
missile.avelocity='0 500 0';
missile.angles=vectoangles('0 100 0');
missile.spikes=200 + 300*random(); // time to blow up
missile.velocity='0 0 50';
missile.touch=GrenadeTouch;
missile.nextthink=time+0.5;
missile.think=GrenadeVibrate;
missile.wait = 0;
setmodel (missile, "progs/grenade.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, self.origin);
};
//=============================================================================
void() spike_touch;
void() superspike_touch;
/*
===============
launch_spike
Used for both the player and the ogre
===============
*/
void(vector org, vector dir) launch_spike =
{
newmis = spawn ();
newmis.owner = self;
if (self.owner.classname == "player")
newmis.owner = self.owner;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.touch = spike_touch;
newmis.classname = "spike";
newmis.think = SUB_Remove;
newmis.nextthink = time + 6;
setmodel (newmis, "progs/spike.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 1000;
};
void() W_FireSuperSpikes =
{
local vector dir;
local entity old;
sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 2;
dir = aim (self, 1000);
launch_spike (self.origin + '0 0 16', dir);
newmis.touch = superspike_touch;
setmodel (newmis, "progs/s_spike.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
self.punchangle_x = -2;
};
void(float ox) W_FireSpikes =
{
local vector dir;
local entity old;
makevectors (self.v_angle);
if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
{
W_FireSuperSpikes ();
return;
}
if (self.ammo_nails < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 1;
dir = aim (self, 1000);
launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
self.punchangle_x = -2;
};
/*
=========
Modified by Piramida
Spike Stuffer script (c)
=========
*/
void() SPIKExplode =
{ local entity victim;
self.wait = self.wait - 1;
victim = self.trigger_field;
if ((self.wait == 40) || (self.wait == 30) || (self.wait == 20) || (self.wait == 10))
sound (self, CHAN_WEAPON, "player/tornoff2.wav", 1, ATTN_NORM);
if ((self.wait == 45) ||(self.wait == 35) || (self.wait == 25) || (self.wait == 15))
sound (self, CHAN_WEAPON, "player/lburn1.wav", 1, ATTN_NORM);
if ((!self.wait) || (victim.health <= 10))
{
T_RadiusDamage (self, self.owner, 10 * self.spikes, self.owner);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion ();
if(victim.health > 0)
{
victim.spikes = 0;
victim.lastspike = world;
}
return;
}
T_Damage (victim, self, self.owner, 0.04 * self.spikes);
spawn_touchblood (self.spikes);
self.origin = victim.origin + '0 0 12';
self.nextthink = time + 0.05;
self.think = SPIKExplode;
};
void() spike_touch =
{
local float damg;
if (other == self.owner)
return; // don't explode on owner
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
if (other.takedamage)
{
if (self.owner.classname != "player")
{
spawn_touchblood (9);
T_Damage (other, self, self.owner, 9);
}
else
{
sound (self, CHAN_WEAPON, "player/tornoff2.wav", 1, ATTN_NORM);
self.trigger_field = other;
self.origin = other.origin + '0 0 12';
self.nextthink = time + 0.1;
self.think = SPIKExplode;
self.movetype = MOVETYPE_NOCLIP;
self.velocity = '0 0 0' ;
if ((other.spikes) && (other.lastspike.classname == "spike")) //If spikes are in the victims body
{
other.spikes = other.spikes + 1;
remove(other.lastspike);
}
else
other.spikes = 1;
self.wait = 40;
self.spikes = other.spikes;
other.lastspike = self;
return;
}
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
if (self.classname == "wizspike")
WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
else if (self.classname == "knightspike")
WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
else
WriteByte (MSG_BROADCAST, TE_SPIKE);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
}
remove(self);
};
void() superspike_touch =
{
local float damg;
if (other == self.owner)
return; // don't explode on owner
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
if (other.takedamage)
{
if (self.owner.classname != "player")
{
spawn_touchblood (18);
T_Damage (other, self, self.owner, 18);
}
else
{
sound (self, CHAN_WEAPON, "player/tornoff2.wav", 1, ATTN_NORM);
self.trigger_field = other;
self.origin = other.origin + '0 0 12';
self.nextthink = time + 0.1;
self.think = SPIKExplode;
self.movetype = MOVETYPE_NOCLIP;
self.velocity = '0 0 0' ;
if ((other.spikes) && (other.lastspike.classname == "spike")) //If spikes are in the victims body
{
other.spikes = other.spikes + 2;
remove(other.lastspike);
}
else
{
other.spikes = 2;
}
self.wait = 50;
self.spikes = other.spikes;
other.lastspike = self;
return;
}
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
}
remove(self);
};
// End of spike stuffer
/*
===============================================================================
PLAYER WEAPON USE
===============================================================================
*/
void() W_SetCurrentAmmo =
{
player_run (); // get out of any weapon firing states
self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
if (self.weapon == IT_AXE)
{
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
}
else if (self.weapon == IT_SHOTGUN)
{
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
self.items = self.items | IT_SHELLS;
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_shot2.mdl";
self.weaponframe = 0;
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_NAILGUN)
{
self.currentammo = self.ammo_nails;
self.weaponmodel = "progs/v_nail.mdl";
self.weaponframe = 0;
self.items = self.items | IT_NAILS;
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
self.currentammo = self.ammo_nails;
self.weaponmodel = "progs/v_nail2.mdl";
self.weaponframe = 0;
self.items = self.items | IT_NAILS;
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock.mdl";
self.weaponframe = 0;
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock2.mdl";
self.weaponframe = 0;
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_LIGHTNING)
{
self.currentammo = self.ammo_cells;
self.weaponmodel = "progs/v_light.mdl";
self.weaponframe = 0;
self.items = self.items | IT_CELLS;
}
else
{
self.currentammo = 0;
self.weaponmodel = "";
self.weaponframe = 0;
}
};
float() W_BestWeapon =
{
local float it;
it = self.items;
if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
return IT_LIGHTNING;
else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
return IT_SUPER_NAILGUN;
else if(self.ammo_rockets >= 3 && (it & IT_SUPER_SHOTGUN) )
return IT_SUPER_SHOTGUN;
else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
return IT_NAILGUN;
else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
return IT_SHOTGUN;
if((self.ammo_rockets >= 1) && (it & IT_ROCKET_LAUNCHER) && (self.ammo_cells >= 1) && (self.ammo_nails >= 1) && (self.ammo_shells >= 1))
return IT_ROCKET_LAUNCHER;
else if(self.ammo_rockets >= 2 && (it & IT_GRENADE_LAUNCHER) )
return IT_GRENADE_LAUNCHER;
return IT_AXE;
};
float() W_CheckNoAmmo =
{
if (self.currentammo > 0)
return TRUE;
if (self.weapon == IT_AXE)
return TRUE;
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
// drop the weapon down
return FALSE;
};
/*
============
W_Attack
An attack impulse can be triggered now
============
*/
void() player_shot1;
void() player_nail1;
void() player_light1;
void() player_rocket1;
void() player_chain1;
void() player_chain3;
void() W_Attack =
{
local float r;
if (!W_CheckNoAmmo ())
return;
makevectors (self.v_angle); // calculate forward angle for velocity
self.show_hostile = time + 1; // wake monsters up
if (self.weapon == IT_AXE)
{
if (!self.hook_out)
player_chain1();
else
player_chain3();
self.attack_finished = time + 0.1;
}
else if (self.weapon == IT_SHOTGUN)
{
player_shot1 ();
W_FireShotgun ();
self.attack_finished = time + 0.4;
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
player_rocket1 ();
W_FireSuperShotgun ();
self.attack_finished = time + 1.2;
}
else if (self.weapon == IT_NAILGUN)
{
player_nail1 ();
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
player_nail1 ();
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
player_rocket1();
W_FireGrenade();
self.attack_finished = time + 0.8;
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
player_rocket1();
W_FireRocket();
self.attack_finished = time + 2.5;
}
else if (self.weapon == IT_LIGHTNING)
{
player_light1();
self.attack_finished = time + 0.1;
sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
}
};
/*
============
W_ChangeWeapon
============
*/
void() W_ChangeWeapon =
{
local float it, am, fl;
it = self.items;
am = 0;
if (self.impulse == 1)
{
fl = IT_AXE;
}
else if (self.impulse == 2)
{
fl = IT_SHOTGUN;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.impulse == 3)
{
fl = IT_SUPER_SHOTGUN;
if (self.ammo_rockets < 3)
am = 1;
}
else if (self.impulse == 4)
{
fl = IT_NAILGUN;
if (self.ammo_nails < 1)
am = 1;
}
else if (self.impulse == 5)
{
fl = IT_SUPER_NAILGUN;
if (self.ammo_nails < 2)
am = 1;
}
else if (self.impulse == 6)
{
fl = IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 4)
am = 1;
}
else if (self.impulse == 7)
{
fl = IT_ROCKET_LAUNCHER;
if ((self.ammo_rockets < 1) || (self.ammo_cells < 1) || (self.ammo_nails < 1) || (self.ammo_shells < 1))
am = 1;
}
else if (self.impulse == 8)
{
fl = IT_LIGHTNING;
if (self.ammo_cells < 1)
am = 1;
}
self.impulse = 0;
if (!(self.items & fl))
{ // don't have the weapon or the ammo
sprint (self, "no weapon.\n");
return;
}
if (am)
{ // don't have the ammo
sprint (self, "not enough ammo.\n");
return;
}
//
// set weapon, set ammo
//
self.weapon = fl;
W_SetCurrentAmmo ();
};
/*
============
CheatCommand
============
*/
void() CheatCommand =
{
if (deathmatch || coop)
return;
self.ammo_rockets = 100;
self.ammo_nails = 200;
self.ammo_shells = 100;
self.items = self.items |
IT_AXE |
IT_SHOTGUN |
IT_SUPER_SHOTGUN |
IT_NAILGUN |
IT_SUPER_NAILGUN |
IT_GRENADE_LAUNCHER |
IT_ROCKET_LAUNCHER |
IT_KEY1 | IT_KEY2;
self.ammo_cells = 200;
self.items = self.items | IT_LIGHTNING;
self.weapon = IT_SUPER_SHOTGUN;
self.impulse = 0;
W_SetCurrentAmmo ();
};
/*
============
CycleWeaponCommand
Go to the next weapon with ammo
============
*/
void() CycleWeaponCommand =
{
local float it, am;
it = self.items;
self.impulse = 0;
while (1)
{
am = 0;
if (self.weapon == IT_LIGHTNING)
{
self.weapon = IT_AXE;
}
else if (self.weapon == IT_AXE)
{
self.weapon = IT_SHOTGUN;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.weapon == IT_SHOTGUN)
{
self.weapon = IT_SUPER_SHOTGUN;
if (self.ammo_rockets < 2)
am = 1;
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
self.weapon = IT_NAILGUN;
if (self.ammo_nails < 1)
am = 1;
}
else if (self.weapon == IT_NAILGUN)
{
self.weapon = IT_SUPER_NAILGUN;
if (self.ammo_nails < 2)
am = 1;
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
self.weapon = IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 4)
am = 1;
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
self.weapon = IT_ROCKET_LAUNCHER;
if ((self.ammo_rockets < 1) || (self.ammo_cells < 1) || (self.ammo_nails < 1) || (self.ammo_shells < 1))
am = 1;
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
self.weapon = IT_LIGHTNING;
if (self.ammo_cells < 1)
am = 1;
}
if ( (self.items & self.weapon) && am == 0)
{
W_SetCurrentAmmo ();
return;
}
}
};
/*
============
ServerflagsCommand
Just for development
============
*/
void() ServerflagsCommand =
{
serverflags = serverflags * 2 + 1;
};
void() QuadCheat =
{
if (deathmatch || coop)
return;
self.super_time = 1;
self.super_damage_finished = time + 30;
self.items = self.items | IT_QUAD;
dprint ("quad cheat\n");
};
/*
============
ImpulseCommands
============
*/
void() ImpulseCommands =
{
if (self.impulse >= 1 && self.impulse <= 8)
W_ChangeWeapon ();
if (self.impulse == 9)
CheatCommand ();
if (self.impulse == 10)
CycleWeaponCommand ();
if (self.impulse == 11)
ServerflagsCommand ();
if (self.impulse == 100)
DetonateAllGrenades ();
if (self.impulse == 255)
QuadCheat ();
self.impulse = 0;
};
/*
============
W_WeaponFrame
Called every frame so impulse events can be handled as well as possible
============
*/
void() W_WeaponFrame =
{
if (time < self.attack_finished)
return;
ImpulseCommands ();
// check for attack
if (self.button0)
{
SuperDamageSound ();
W_Attack ();
}
};
/*
========
SuperDamageSound
Plays sound if needed
========
*/
void() SuperDamageSound =
{
if (self.super_damage_finished > time)
{
if (self.super_sound < time)
{
self.super_sound = time + 1;
sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
}
}
return;
};
/*
========
shrapnel shooter for Grenade Bomb
by Piramida
========
*/
void(float spin, entity spawner, float ox, float oy) shrapnel =
{
local float xdir, ydir, zdir;
xdir = 100 * random() - 50 + ox;
ydir = 100 * random() - 50 + oy;
zdir = 800 * random();
newmis = spawn ();
newmis.owner = spawner.owner;
newmis.movetype = MOVETYPE_BOUNCE;
newmis.solid = SOLID_BBOX;
newmis.touch = GrenadeTouch;
newmis.think = GrenadeExplode;
newmis.nextthink = time + 1 + random();
newmis.velocity_x = xdir * 5;
newmis.velocity_y = ydir * 5;
newmis.velocity_z = zdir * 5;
setmodel (newmis, "progs/grenade.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, spawner.origin);
if (spin == 0)
newmis.avelocity='250 300 400';
if (spin == 1)
newmis.avelocity='400 250 300';
if (spin == 2)
newmis.avelocity='300 400 250';
if (spin == 3)
newmis.avelocity='300 300 300';
if (spin == 4)
newmis.avelocity='400 250 300';
if (spin == 5)
newmis.avelocity='100 250 500';
if (spin == 6)
newmis.avelocity='400 150 300';
if (spin == 7)
newmis.avelocity='400 550 100';
if (spin == 8)
newmis.avelocity='200 350 400';
if (spin == 9)
newmis.avelocity='100 250 100';
if (spin == 10)
newmis.avelocity='800 50 10';
};
/*
=============
Fire Protection (nails)
==============
*/
void() MissileForward =
{
self.velocity = self.v_angle * 150;
self.nextthink = time + 0.1;
self.think = MissileMove;
};
void() MissileBack =
{
self.velocity = self.v_angle * -150;
self.nextthink = time + 0.1;
self.think = MissileForward;
};
void() ProtectionFire =
{
local vector dir,vtemp;
local entity old;
vtemp = self.enemy.origin + '0 0 10';
dir = normalize(vtemp - self.origin);
self.avelocity = '0 0 0';
self.angles = vectoangles(dir);
self.v_angle = dir;
sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
launch_spike (self.origin, dir);
self.nextthink = time + 0.1;
self.think = MissileBack;
};
/*
==========
Super Protection
by Piramida
==========
*/
entity() FindEnemy =
{
local entity head, selected;
local float dist;
dist = 5000;
selected = world;
head = findradius(self.origin, 5000);
while(head)
{
if( (head.health > 1) && (head != self.owner) /*&& (head.classname == "player")*/)
{
traceline(self.owner.origin + '0 0 35',head.origin,TRUE,self);
if ( (trace_fraction >= 1) && (vlen(head.origin - '0 0 35' - self.owner.origin) < dist) )
{
selected = head;
dist = vlen(head.origin - self.origin - '0 0 35');
}
}
head = head.chain;
}
return selected;
};
void() MissileMove =
{
if(self.owner.isprotected == 0)
{
self.velocity = self.v_angle * 20;
self.nextthink = time + 5;
self.num = 204;
self.think = MissileRemove;
return;
}
if ((self.num >= 100) || (self.owner.deadflag == DEAD_DYING)) //protection exhausted
{
self.nextthink = time + 0.1;
self.think = MissileRemove;
return;
}
makevectors(self.owner.v_angle);
self.origin = self.owner.origin;
self.velocity = '0 0 0';
if(self.spikes == 1)
{
self.origin_x = self.origin_x + 11;
self.origin_y = self.origin_y + 17;
}
if(self.spikes == 2)
{
self.origin_x = self.origin_x + 11;
self.origin_y = self.origin_y - 17;
}
if(self.spikes == 3)
self.origin_x = self.origin_x - 20;
self.origin_z = self.origin_z + 35;
self.nextthink = time + 0.1;
self.think = MissileMove;
//perform action
if(!(self.enemy) || (self.enemy.health < 1) || (self.enemy == world) )
{
self.avelocity = '300 300 300';
self.enemy = FindEnemy();
}
else
{
traceline(self.origin,self.enemy.origin,TRUE,self);
if ( (trace_fraction < 1) )
{
self.avelocity = '300 300 300';
self.enemy = FindEnemy();
}
else
{
self.num = self.num + 1;
self.nextthink = time + 0.1;
self.think = ProtectionFire;
}
}
};
void(entity master, float number) StartMissile =
{
local entity miss;
master.isprotected = 1;
miss = spawn();
miss.solid = SOLID_NOT;
miss.classname = "Satellite";
// miss.touch = ; ??? No fucking idea
miss.movetype = MOVETYPE_FLYMISSILE;
miss.owner = master;
miss.velocity = '0 0 0';
miss.avelocity = '300 300 300';
miss.spikes = number;
makevectors(miss.owner.v_angle);
miss.origin = miss.owner.origin;
if(miss.spikes == 1)
{
miss.origin_x = miss.origin_x + 11;
miss.origin_y = miss.origin_y + 17;
}
if(miss.spikes == 2)
{
miss.origin_x = miss.origin_x + 11;
miss.origin_y = miss.origin_y - 17;
}
if(miss.spikes == 3)
miss.origin_x = miss.origin_x - 20;
miss.origin_z = miss.origin_z + 35;
miss.nextthink = 0.1;
miss.think = MissileMove;
miss.num = 0;
setmodel(miss, "progs/grenade.mdl");
};
void() MissileRemove =
{
if(self.owner.isprotected == 1)
{
self.velocity = self.v_angle * 20;
sprint(self.owner,"Super Protection is wearing off\n");
sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
self.owner.effects = self.effects | EF_DIMLIGHT;
self.owner.isprotected = 0;
self.nextthink = time + 1.5;
self.num = 201;
self.think = MissileMove;
return;
}
if(self.num == 201)
{
sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
self.nextthink = time + 1.5;
self.think = MissileMove;
self.num = 202;
return;
}
if(self.num == 202)
{
sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
self.nextthink = time + 2;
self.think = MissileMove;
self.num = 203;
return;
}
if(self.num == 203)
{
self.owner.effects = self.owner.effects - (self.effects & EF_DIMLIGHT);
self.movetype=MOVETYPE_NONE;
self.velocity='0 0 0';
self.nextthink=time + 0;
self.think = SUB_Remove;
}
else
{
self.movetype=MOVETYPE_NONE;
self.velocity='0 0 0';
self.nextthink=time + 0;
self.think = SUB_Remove;
}
T_RadiusDamage(self,self.owner, 300, self.owner);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion();
};